﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework.Graphics;

namespace Projet_Synthese
{
    public class PartieManager
    {
        public List<Partie> Parties { get; set; }
        public int IdPartie { get; set; }
        public Partie Partie 
        { 
            get 
            { 
                if(Parties==null || IdPartie<0 || IdPartie>=Parties.Count)
                    return null;
                return Parties[IdPartie]; 
            } 
            set 
            {
                if (Parties == null || IdPartie < 0 || IdPartie >= Parties.Count)
                    return;
                Parties[IdPartie] = value; 
            } 
        }
        public void Load(String directory, Texture2D[] texture)
        {
            Parties = new List<Projet_Synthese.Partie>();
            string [] files = Directory.GetFiles("Tangram","*.xml");
            foreach(String file in files)
               Parties.Add(Outils.Load(file,texture));
        }
        public bool Next()
        {
            if (Partie != null && IdPartie < (Parties.Count - 1))
            {
                Partie.Rinitialiser();
                IdPartie++;
                return true;
            }
            return false;
        }
        public bool Prev()
        {
            if (IdPartie > 0)
            {
                Partie.Rinitialiser();
                IdPartie--;
                return true;
            }
            return false;
        }
    }
}
